package cn.test;

import java.util.ArrayList;
import java.util.List;

import cn.test.entity.Friend;
import cn.test.entity.Group;
import cn.test.entity.People;

public class GroupManager {
	private static List<People> pList = new ArrayList<People>();

	static {
		for (int k = 0; k < 1; k++) {
			People p = new People();
			p.setId("10000");
			p.setName("name"+k);
			List<Group> gList=new ArrayList<Group>();
			for (int i = 0; i < 3; i++) {
				Group g = new Group();
				g.setId(i + "00");
				g.setName("gName" + i);
				List<Friend> fList = new ArrayList<Friend>();
				for (int j = 0; j < 4; j++) {
					Friend f = new Friend();
					f.setId("1000" + j*i);
					f.setName("name"+i*j);
					fList.add(f);
				}
				g.setFriends(fList);
				gList.add(g);
			}
			p.setGroups(gList);
			pList.add(p);
		}
	}
	
	public static Object peopleInit(String pid) {
		People p=new People();
		p.setId(pid);
		p.setName("name"+pid);
		
		List<Group> gList=new ArrayList<Group>(); 
		p.setGroups(gList);
		
		Group g=new Group();
		gList.add(g);
		g.setId("g00");
		g.setName("groupTest");
		List<Friend> fList=new ArrayList<Friend>(); 
		for (int i = 0; i < 5; i++) {
			String id="1000" + i;
			if (pid.equals(id)) {
			} else {
				Friend f = new Friend();
				f.setId(id);
				f.setName("name" + i);
				fList.add(f);
			}
		}
		g.setFriends(fList);
		return p;
	}
	
	public static void main(String[] args) {
		System.out.println(peopleInit(10000+""));
//		System.out.println(pList.get(0).toJSONString());
	}

}
